<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var num = parseInt(Math.random() * 100000)
        var str = num.toString()
        // var res = ''
        // for (var i = 0; i < str.length; i++) {
        //     obj[i + 1] = str[i]
        //     res += str[i]
        // }
        console.log('该数共有' + str.length + '位')
        for (var j = 1; j <= str.length; j++) {
            console.log('第' + j + '位为' + str[j - 1])
        }
    </script>
</body>

</html>